package com.example.modelrepositorydemo.Service;

import org.springframework.stereotype.Service;

@Service
public class ArtifactDataServiceImpl implements ArtifactDataService {
    private final ArtifactDataRepository artifactDataRepository;

    public ArtifactDataServiceImpl(ArtifactDataRepository artifactDataRepository) {
        this.artifactDataRepository = artifactDataRepository;
    }

    @Override
    public byte[] getArtifactData(String groupName, String artifactName, String releaseNo) throws ArtifactDataNotFoundException {
        ArtifactData artifactData = artifactDataRepository.findByGroupNameAndArtifactNameAndReleaseNo(groupName, artifactName, releaseNo)
                .orElseThrow(() -> new ArtifactDataNotFoundException("Artifact data not found"));
        return artifactData.getData();
    }
}
